<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML>
<html style='height:100%;'>
  <head>
    <base href="<%=basePath%>">
    
    <title>周边配套列表</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<link rel="stylesheet" href="css/vivo.css">
	<link rel="stylesheet" href="css/bootstrap.css">
	<link rel="stylesheet" href="js/bootstrap2/css/bootstrap.min.css">
	<link rel="stylesheet" href="js/bootstrap2/css/bootstrap-table.css">
	<link rel="stylesheet" href="css/common.css">
	<link rel="stylesheet" href="js/font-awesome/css/font-awesome.css">
    <link href="js/select2/select2.min.css" type="text/css" rel="stylesheet" />
	<link rel="stylesheet" type="text/css" href="js/webuploader-0.1.5/webuploader.css" />
	
	<script src="js/jquery-1.11.1.js"></script>
	<script src="js/bootstrap2/js/bootstrap.min.js"></script>
	<script type="text/javascript" src="js/layui-v2.1.5/layui/layui.all.js"></script> 
	<script type="text/javascript" src="<%=basePath %>js/My97DatePicker/WdatePicker.js"></script> 
	<script src="js/select2/select2.min.js"></script>
    <script type="text/javascript" src="js/sharefunction.js"></script>
    <script type="text/javascript" src="js/form.js"></script>
    <script type="text/javascript" src="js/webuploader-0.1.5/webuploader.js"></script>
    <script src="js/bootstrap2/js/bootstrap-table.js"></script>
	<script src="js/bootstrap2/js/bootstrap-table-zh-CN.js"></script>
<script type="text/javascript">
	 function openAddRim() {
			$("#div_rim").show();
			$("iframe[id='toAddRim']").attr("src", "assortInfo/toAddRim");
		}
</script>
</head>
<body>
	<div style="padding:0px 20px">
		<div class="panel panel-default">
			<div class="panel-body">
				<a  class="btn btn-danger addbtn" onClick='openAddRim()'>新增</a> 
				<!-- 列表start -->
				<div >
					<!-- 周边列表 -->
					<div>
						<table id="table"></table>
					</div>
				</div>
				<!-- 表单start -->
				<div id="div_rim" style="margin-top: 15px;height:500px;display:none;">
					<iframe id="toAddRim" name="toAddRim" width="100%" style="height:100%;" frameborder="0"></iframe>
				</div>
				<!-- 表单end -->
			</div>
		</div>

	</div>
<script type="text/javascript">
$(function() {
			var pid = parent.parent.projectID;
			//先销毁表格  
			//$('#table').bootstrapTable('destroy');  
			//初始化表格,动态从服务器加载数据  
			$("#table").bootstrapTable({
				method : "post", //使用get请求到服务器获取数据  
				url : "assortInfo/getRimAssortList", //获取数据的Servlet地址  
				striped : true, //表格显示条纹  
				pagination : true, //启动分页  
				pageSize : 5, //每页显示的记录数  
				pageNumber : 1, //当前第几页  
				pageList : [ 5, 10, 15, 20, 25 ], //记录数可选列表  
				sidePagination : "server", //表示服务端请求  
				contentType : 'application/x-www-form-urlencoded',
				//设置为undefined可以获取pageNumber，pageSize，searchText，sortName，sortOrder  
				//设置为limit可以获取limit, offset, search, sort, order  
				queryParamsType : "undefined",
				queryParams : function queryParams(params) { //设置查询参数  
					var param = {
						pageNumber : params.pageNumber,
						pageSize : params.pageSize,
						pid : pid
					};
					return param;
				},
				columns : [ {
					field : 'projectInfo.projectName',
					title : '项目名称',
				},{
					field : 'assortType',
					title : '配套类型',
				},{
					field : 'assortName',
					title : '配套名称',
				}, {
					field : 'createDate',
					title : '创建时间',
					formatter : 'dataFormat',
				},{
					field : 'opr',
					title : '操作',
					width : '15%',
					formatter : 'actionFormatter'
				} ]
			});
		});
		//日期格式化
		function dataFormat(value, row, index) {
			if(row.createDate==null){
				return "--";
			}else{
			  	return new Date(row.createDate).format("yyyy-MM-dd");
			}
		}
		//表格-操作 - 格式化 
		function actionFormatter(value, row, index) {
			var html="<a class='btn btn-info' onClick='showRim(\"" + row.id + "\")'>查看</a>";
			<shiro:hasPermission name="permission:edit"> 
				html +="&nbsp;&nbsp;<a class='btn btn-info' onClick='editRim(\"" + row.id + "\")'>修正</a>";
			</shiro:hasPermission> 
			<shiro:hasPermission name="permission:delete"> 
					html +="&nbsp;&nbsp;<a class='btn btn-warning' onClick='delRim(\"" + row.id + "\")'>删除</a>";
			</shiro:hasPermission>  
				return html;
		}
		
		function editRim(id) {
			$("#div_rim").show();
			$("iframe[id='toAddRim']").attr("src", "assortInfo/toAddRim?id=" + id+"&rimFlag=2");
		}
		//查看周边配套信息
		function showRim(id) {
			$("#div_rim").show();
			$("iframe[id='toAddRim']").attr("src", "assortInfo/toAddRim?id=" + id+"&rimFlag=1");
		}
		
		function delRim(id) {
			layer.confirm('确定删除该条信息吗？', {
				btn : [ '确定', '取消' ] //按钮
			}, function() {
				$.getJSON("assortInfo/delRim", {
					id :id
				}, function(data, status) {
					if (status == "success") {
						layer.msg("删除成功！",{
				    		anim: 5,
				    		time: 300
				    	},function(){
				    		location.reload();
				    	});
					}
				})
			}, function() {
				layer.close();
			});
		}
</script>
</body>
</html>
